package logic

import (
	"context"
	"day01/day01rpc/models"
	"math/rand"
	"time"

	"day01/day01rpc/day01rpc"
	"day01/day01rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLogic {
	return &SendSmsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 短信
func (l *SendSmsLogic) SendSms(in *day01rpc.SendSmsRequest) (*day01rpc.SendSmsResponse, error) {
	// todo: add your logic here and delete this line
	code := rand.Intn(9000) + 1000
	models.Rdb.Set(l.ctx, "sendsms"+in.Account, code, time.Minute*5)
	return &day01rpc.SendSmsResponse{}, nil
}
